import request from '@/service';
import { IAccount, IRequest, ILoginResult } from './type';

enum LoginApi {
  AccountLogin = '/login',
  LoginUserInfo = '/users/', // 用法: /users/1
  UserMenus = '/role/', // 用法: role/1/menu
}

export function accountLoginRequest(account: IAccount) {
  return request.post<IRequest<ILoginResult>>({
    url: LoginApi.AccountLogin,
    data: account,
    showLoading: false,
  });
}

export function requestUserInfoById(id: number) {
  return request.get<IRequest>({
    url: LoginApi.LoginUserInfo + id,
  });
}

export function requestUserMenusByRoleId(id: number) {
  return request.get<IRequest>({
    url: LoginApi.UserMenus + id + '/menu',
  });
}
